/*
 * @Description:
 * @Author: zhaolei
 * @Date: 2023-04-15 10:28:59
 */
import {
  SEARCH_TYPE_LIST,
  SEARCH_TYPE,
  ADVERTISING_STATUS_LIST,
} from '@/const/type';
export const tableOption = () => {
  return {
    ...window.$crudMixins.tableOptions,
    addBtn: true,
    editBtn: true,
    delBtn: false,
    menuWidth: 160,
    searchLabelWidth: 110,
    viewBtn: true,
    editBtnText: '修改',
    column: [
      {
        label: '搜索词编号',
        prop: 'id',
        addDisplay: false,
        editDisplay: false,
      },
      {
        label: '搜索词',
        prop: 'searchName',
        search: true,
        rules: [
          {
            required: true,
            message: '请输入广告名称',
          },
          {
            pattern: /^[\u4e00-\u9fa5]{1,10}$/,
            message: '请输入汉字，最多10个',
            trigger: 'blur',
          },
        ],
      },
      {
        label: '持续时间',
        prop: 'duration',
        width: 180,
        format: 'yyyy-MM-dd',
        valueFormat: 'yyyy-MM-dd',
        searchRange: true,
        search: true,
        searchType: 'daterange',
        addDisplay: false,
        editDisplay: false,
        viewDisplay: true,
      },
      {
        label: '持续时间',
        prop: 'durationForm',
        format: 'yyyy-MM-dd',
        valueFormat: 'yyyy-MM-dd',
        searchRange: true,
        type: 'daterange',
        rules: [
          {
            required: true,
            message: '请选择持续时间',
          },
        ],
        addDisplay: true,
        editDisplay: true,
        viewDisplay: false,
        hide: true,
      },
      {
        label: '跳转类型',
        prop: 'jumpType',
        search: true,
        type: 'select',
        dicData: SEARCH_TYPE_LIST,
        rules: [
          {
            required: true,
            message: '请选择跳转类型',
          },
        ],
        control: (val, form) => {
          if (val === SEARCH_TYPE.PET_RESULT) {
            return {
              jumpDetail: {
                display: false,
              },
              keywordsJson: {
                display: true,
              },
            };
          } else {
            return {
              jumpDetail: {
                display: true,
              },
              keywordsJson: {
                display: false,
              },
            };
          }
        },
      },
      // {
      //   label: '跳转详情',
      //   prop: 'jumpDetail',
      //   // addDisplay: false,
      //   // editDisplay: false,
      //   // viewDisplay: false,
      // },
      {
        label: '跳转链接',
        prop: 'jumpDetail',
        display: true,
        width: 360,
        overHidden: true,
        rules: [
          {
            required: true,
            message: '请输入跳转链接',
          },
        ],
        span: 12,
      },
      {
        label: '状态',
        prop: 'status',
        type: 'select',
        search: true,
        addDisplay: false,
        editDisplay: false,
        dicData: ADVERTISING_STATUS_LIST,
      },
      {
        label: '跳转详情',
        prop: 'keywordsJson',
        rules: [
          {
            required: false,
            message: '请选择关联以下筛选条件',
          },
        ],
        hide: true,
        span: 24,
      },
    ],
  };
};
